# Last Change: Sat Jan 24 04:00 PM 2009 J
# vim:syntax=python
from os.path import join as pjoin

from numscons import GetNumpyEnvironment
from numscons import CheckF77Mangling

env = GetNumpyEnvironment(ARGUMENTS)
env.Tool('f2py')

config = env.NumpyConfigure(custom_tests = {'CheckF77Mangling' : CheckF77Mangling})
config.CheckF77Mangling()
config.Finish()

# Build dfftpack
src = [pjoin("src/dfftpack", i) for i in [ "dcosqb.f", "dcosqf.f", "dcosqi.f",
"dcost.f", "dcosti.f", "dfftb.f", "dfftb1.f", "dfftf.f", "dfftf1.f", "dffti.f",
"dffti1.f", "dsinqb.f", "dsinqf.f", "dsinqi.f", "dsint.f", "dsint1.f",
"dsinti.f", "zfftb.f", "zfftb1.f", "zfftf.f", "zfftf1.f", "zffti.f",
"zffti1.f"]]
dfftpack = env.DistutilsStaticExtLibrary('dfftpack', source = [str(s) for s in src])

# Build fftpack (single prec)
src = [pjoin("src/fftpack", i) for i in [ 'cfftb.f', 'cfftb1.f', 'cfftf.f',
'cfftf1.f', 'cffti.f', 'cffti1.f', 'cosqb.f', 'cosqf.f', 'cosqi.f', 'cost.f',
'costi.f', 'rfftb.f', 'rfftb1.f', 'rfftf.f', 'rfftf1.f', 'rffti.f',
'rffti1.f', 'sinqb.f', 'sinqf.f', 'sinqi.f', 'sint.f', 'sint1.f', 'sinti.f']]
fftpack = env.DistutilsStaticExtLibrary('fftpack', source = [str(s) for s in src])

env.PrependUnique(LIBS = ['fftpack', 'dfftpack'])
env.PrependUnique(LIBPATH = ['.'])

# Build _fftpack
src = ['src/zfft.c','src/drfft.c','src/zrfft.c', 'src/zfftnd.c', 'fftpack.pyf']
src += env.FromCTemplate('src/dct.c.src')
env.NumpyPythonExtension('_fftpack', src)

# Build convolve
src = ['src/convolve.c',  'convolve.pyf']
env.NumpyPythonExtension('convolve', src)
